package cn.wolfcode.luowowo.redis.util;

import cn.wolfcode.luowowo.common.util.Consts;
import lombok.Getter;

@Getter
public enum RedisKeys {
    //国内外推荐
    STRATEGY_ZSET_SORT_ISABROAD("strategy_zset_sort_isabroad",-1L),
    //热门推荐key
    STRATEGY_ZSET_SORT_HOT("strategy_zset_sort_hot",-1L),
    //攻略点赞key
    STRATEGY_STATIS_THUMBUP("STRATEGY_STATIS_THUMBUP",-1L),//约定-1的时间为不需要过期
    //攻略手藏数
    STRATEGY_STATIS_FAVOR("strategy_statis_favor",-1L),//约定-1的时间为不需要过期

    //攻略统计对象key
    STRATEGY_STATIS_VO("strategy_statis_vo",-1L),//约定-1的时间为不需要过期

    //检查短信发送频率
    VERIFY_CODE_VALI("verify_code_vali",Consts.FREQUENCY_VERIFY_CODE_VAI_TIME * 60L),
    //登录token  key
    USER_LOGIN("user_login",Consts.USER_INFO_TOKEN_VAI_TIME * 60L),//单位为秒
    //定义一个前缀验证码    发送短信
    VERIFY_CODE("verify_code", Consts.VERIFY_CODE_VAI_TIME * 60L);//单位为秒

    private String prefix;
    private Long time;

    private RedisKeys(String prefix,Long time){
        this.prefix = prefix;
        this.time = time;
    }

    //完整的验证码key
    public  String getKey(String ... value){
        StringBuilder sb = new StringBuilder(30);
        sb.append(prefix);
        for (String v : value) {
            sb.append(":").append(v);
        }
        return sb.toString();
    }
}
